/******************************************************************************
 * $Id: text.h,v 1.7 2004/09/22 01:14:28 jimb Exp $
 * @file
 * @author  Jim Brooks http://www.jimbrooks.org
 ******************************************************************************/

#ifndef TEXT_H
#define TEXT_H

#include<gtksourceview/gtksourcebuffer.h>
#include<gtksourceview/gtksourceview.h>

void
CreateTextWidgetEtAl( GtkWidget**  ppWidgetText,	/*OUT*/
                      GtkWidget**  ppWidgetVbox,	/*OUT*/
                      GtkWidget**  ppWidgetTable,	/*OUT*/
                      GtkWidget**  ppWidgetVscroll,	/*OUT*/
                      GtkWidget**  ppWidgetHscroll,	/*OUT*/
                      focusbar_t** ppFocusbar		/*OUT*/ );

void
ConnectHandlersForTextWidget( GtkWidget* pWidget );

void
ApplyTabWidth( GtkWidget* pWidget,
               int        width );

FUNC_X
LoadTextWidgetWithModule( gchar*   pModuleName,
                          gint	   cursor,
                          gint     row,
                          gboolean reload );

void
LoadTextWidgetWithBuffer( gpointer pBuffer,
                          gint     bufferSize,
                          int      srcFileKind );

gboolean
cb_RefreshAuxTextWidget( gpointer data );

void
RefreshAuxTextWidget();

void
RefreshTextWidget ( GtkWidget * pWidgetText,
                    module_t  * pModule );
                    
GString*
WordAtCursor ( void );

void
ClearTextWidget( void );

void
RedrawBothTextWidgets( void );

void
RedrawActiveTextWidget( void );

int
IsTextWidgetEmpty( void );

gint
OffsetAtCursor(void);

int
LineAtCursor( void );

void
ScrollToCursor(GtkTextView *pView, gdouble within_margin);

void
ScrollTextWidgetToLine( gint   line,
                        gfloat vertFrac );

void
SetAdjustmentValue( GtkAdjustment* pAdj,
                    gfloat         adjust );

void
RecenterTextWidget( void );

void
RecordLocationAsPrevious( void );

void
GotoPrev( void );

void
GotoLine( void );

gboolean
HighlightLine( int line );

void
HighlightWordInCurrentLine( const char* pWord,
                            gboolean    caseSens,
                            int         searchMethod,
                            gboolean    tryConstructorMatch );

void
HighlightTextString( gchar* pText,
                     gint   idx,
                     gint   len );

void
HighlightTag( tag_t* pTag,
              guint  idxCursor );

void
HighlightChar( int line,
               int idxText );

int
PrintLineNum( void );

gint
IdleLineNum( gpointer dontCare );

void
SelectRegion( GtkTextBuffer* pBuf,
              int      idxStart,
              int      idxEnd );

gint
IdleSelectRegion( gpointer unused );

guint
TextCursorIdx( void );

gboolean
IsCursorOverWord( void );

gboolean
IsWordChar( gunichar c );

GString*
ScoopWordAtCursor( int   maxWordLen,
                   char* pText,
                   int   textLen,
                   int   idxCursor );

void
SaveCursor( cursor_t* pCursor );

void
RestoreCursor( cursor_t* pCursor );

char*
ActiveTextWidgetContents( guint* pSizeOut );

guint
ActiveTextWidgetSize( void );

void
SetActiveTextWidget( GtkWidget* pWidget );

void
GiveFocusToTextWidget( GtkWidget* pWidget );

void
SwitchActiveTextWidget( gboolean whicheverHasFocus );

void
RecordActiveModuleName( char* pModuleName );

char*
ActiveModuleName( void );

void
RecordActiveModule( module_t* pModule );

module_t*
ActiveModule( void );

module_t*
GetModuleTextMain( void );

module_t*
GetModuleTextAux( void );

GtkWidget*
GetWidgetTextMain( void );

void
SetModuleTextMain( module_t *pModule );

GtkWidget*
GetWidgetTextAux( void);

void
SetModuleTextAux( module_t *pModule );

gboolean
IsMainTextViewHaveContents(void);

gboolean
IsMainModuleModified(void);

gboolean
SetBufferHighlight(GtkSourceBuffer *buffer, const gchar * filename);

void
SetMainModuleModified(gboolean IsModified);

#endif /* TEXT_H */

